package com.frxuexi.park2209_2.hourse

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.frxuexi.base.mvvm.BaseActivity
import com.frxuexi.park2209_2.R
import com.frxuexi.park2209_2.adapter.HourseDetailAdapter
import com.frxuexi.park2209_2.databinding.ActivityHourseDetailBinding
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class HourseDetailActivity : BaseActivity<ActivityHourseDetailBinding,HourseViewModel>() {
    val hourseDetailAdapter by lazy { HourseDetailAdapter() }
    override fun initData() {
        vm.hourseDetailSuc.observe(this){
            Log.i("===",it.toString())
            Glide.with(this).load(it.indexPictureUrl).centerCrop().into(binding.topimg)

            hourseDetailAdapter.addData(it.labelDesc.split("|"))
            hourseDetailAdapter.notifyDataSetChanged()

            binding.detailTitle.text=it.title
            binding.detailPrice.text=it.price.toString()
            binding.detailXing.text="${it.bedRoom}室${it.livingRoom}厅"
            binding.detailPing.text=it.area.toString()

        }
    }

    override fun initView() {
        binding.rvLabel.apply {
            adapter=hourseDetailAdapter
            layoutManager=LinearLayoutManager(this@HourseDetailActivity,RecyclerView.HORIZONTAL,false)
        }
        vm.getHourseDetail()
    }

}